# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Contributor: Michael Mason <ms13sp@gmail.com>
# Maintainer: Sören Tempel <soeren+alpine@soeren-tempel.net>
pkgname=ctags
pkgver=6.1.20240421.0
_realver="p$pkgver"
pkgrel=0
pkgdesc="Generator of tags for all types of C/C++ languages"
url="https://ctags.io/"
arch="all"
license="GPL-2.0-or-later"
checkdepends="diffutils python3"
makedepends="autoconf automake pkgconf py3-docutils yaml-dev jansson-dev"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/universal-ctags/ctags/archive/$_realver.tar.gz"
builddir="$srcdir"/$pkgname-$_realver

# secfixes:
#   5.8-r5:
#     - CVE-2014-7204

prepare() {
	default_prepare
	./autogen.sh

	# Fail, likely due to compatibility issues with musl's iconv.
	# Alternative solution: Build ctags with --disable-iconv.
	rm -r Tmain/input-encoding-option.d \
		Tmain/output-encoding-option.d
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--disable-external-sort \
		--enable-json \
		--enable-yaml
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

sha512sums="
eebb836a45daed5d79d7a45a7b922212000e041a82f9abc17ddd9db214572efe211d908cc40b00f7c48057f8d331be965e0b082569f289117bb0bb99bb55b3c1  ctags-6.1.20240421.0.tar.gz
"
